#define  STACK_INIT_SIZE  100; 
typedef struct {
    ElemType  *base;    
    ElemType  *top;  
    int  stacksize;    
} SqStack;
/*
#define  STACK_INIT_SIZE  100; 
typedef struct Node{
    ElemType  data;    
    Node           *next;
} *LinkStack;
 */
/*
InitStack(&S)
DestroyStack(&S)
StackLength(S)
StackEmpty(s)
GetTop(S, &e)
ClearStack(&S)
Push(&S, e)
Pop(&S, &e)
StackTravers(S)
*/

Status InitStack (SqStack *S, int maxsize)
{  // 构造一个最大空间为 maxsize 的空顺序栈 S
	S->base = (ElemType*)malloc(sizeof(ElemType)*maxsize);
	if (!S->base) exit (OVERFLOW); //存储分配失败
	S->top = S->base;
	S->stacksize = maxsize;
	return OK;
}

Status Push (SqStack *S, ElemType e) 
{
	if (S->top – S->base >= S->stacksize) //栈满
		return OVERFLOW;
	*S->top++ = e;
		return OK;
}

Status Pop (SqStack *S, ElemType *e) 
{
     // 若栈不空，则删除S的栈顶元素，
     // 用 e 返回其值，并返回OK；
     // 否则返回ERROR
	if (S->top == S->base) 
		return ERROR;
	e = --S->top;
	return OK;
}
